from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as ES
import time

driver = webdriver.Chrome()
driver.maximize_window()
driver.get("https://www.baidu.com")
driver.implicitly_wait(10)

# # 点击-搜索设置
# driver.find_element(By.XPATH, "//span[text()='搜索设置']").click()

start_time = time.time()

try:
    # # 显式等待查找元素
    # ele = WebDriverWait(driver, 10, 0.5).until(ES.presence_of_element_located((By.XPATH, "//span[text()='搜索设置']")))
    ele = driver.find_element(By.XPATH, "//span[text()='搜索设置']")
    ele.click()
except:
    pass
end_time = time.time()
print("共耗时：", end_time-start_time)

driver.quit()